import requests,unittest
class a():
    def test_add1(self):
        con = requests.post(url="http://localhost:8000/api/add_event/",
                      data={"eid":"1","name":"发布会标题".encode(),"limit":"500","address":"成都".encode(),
                            "start_time":"2016-09-11 12:00:00"
                            }
                      )
        print(con.text)
        # r = con.text
        # d={}
        # d.fromkeys(r)
        # print(type(r))
# if __name__ == "__main__":
#     unittest.main()
        #r = eval(con.text)
        #R1 = r["status"]
        #R2 = r["message"]
        #print(R1)
        #print(R2)
        #li = [{"status": 10021, "message": "parameter error"},
              # {"status": 10022, "message": "event id already exists"},
              # {"status": 10023, "message": "event name already exists"},
              # {"status": 10024, "message": "start_time format error. It must be in YYYY-MM-DD HH:MM:SS format"}]
        #self.assertIn(r,li,msg="不通过")
        #print("通过！")
        con = requests.post(url="http://localhost:8000/api/add_event/",
                            data={"eid":"","name":"发布会标题2".encode(),
                                  "limit":"500","address":"成都".encode(),
                                  "start_time":"2016-09-11 12:00:00"})
        print(con.json())
        con = requests.post(url="http://localhost:8000/api/add_event/",
                            data={"eid":"3","name":"发布会标题3".encode(),
                                  "limit":"500","address":"成都".encode(),
                                  "start_time":"2016-0900:00"})
        print(con.json())
        con = requests.post(url="http://localhost:8000/api/add_event/",
                            data={"eid":"4","name":"发布会标题4".encode(),
                                  "limit":"500","address":"成都".encode(),
                                  "start_time":"2016-09-12 10:00:00"})
        print(con.json())
        con = requests.post(url="http://localhost:8000/api/add_event/",
                            data={"eid":"50","name":"发布会标题23333".encode(),
                                  "limit":"500","address":"成都".encode(),
                                  "start_time":"2016-09-12 10:00:00"})
        print(con.json())
a().test_add1()
# if __name__ == '__main__':
#     unittest.main()